﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TeamsPortal.DataAccess;

namespace TeamsPortal.ServiceClient
{
    public interface IMessagesServiceClient
    {
        Message Get(int messageId, int topicId);

        List<Message> GetByTopic(int topicId, int? userId, int pageSize, int pageNumber, out int totalMessages);

        /// <summary>
        /// Gets top latest message of a topic
        /// </summary>
        List<Message> GetByTopicLatest(int topicId);

        /// <summary>
        /// Gets a list of messages from firstMsg to lastMsg
        /// </summary>
        List<Message> GetByTopic(int topicId, int firstMsg, int lastMsg);


        /// <summary>
        /// Gets an specific amount of messages starting from firstMsg
        /// </summary>
        /// <param name="topicId"></param>
        /// <param name="firstMsg"></param>
        /// <param name="amount"></param>
        /// <param name="initIndex"></param>
        /// <returns></returns>
        List<Message> GetByTopicFrom(int topicId, int firstMsg, int amount);

        /// <summary>
        /// Adds a new message to the topic
        /// </summary>
        /// <exception cref="ValidationException">If the model is not valid</exception>
        void Add(Message message, string ip);

        void UpdateBody(Message message, int editorUserId);

        void Delete(int topicId, int messageId, int userId);

        /// <summary>
        /// Flags / Creates a mark on a message of a topic. The ip of flagger is stored.
        /// </summary>
        /// <param name="ip">Ip of the user creating the flag</param>
        bool Flag(int topicId, int messageId, string ip);

        /// <summary>
        /// Gets a list of flagged messages grouped by topic
        /// </summary>
        List<Topic> ListFlagged();

        bool ClearFlags(int topicId, int messageId);

        bool IsReplied(int msgId, int topicId);
    }
}
